var status = -1;
var level = "07";
var header = "#fn黑体##fs32#B - " + level + " F\r\n\r\n";

function action(e, d, c) {
    status++;
    var b = cm.getEventManager("副本_起源之塔");
    var f = b == null ? null : b.getProperty("stage" + parseInt(level));
    if (f != null && f.equals("start")) {
        cm.dispose();
        return
    }
    if (cm.getInfoQuest(42001).contains("noHelp=1")) {
        cm.spawnNpcForPlayer(2540001, -850, 2300);
        startMap(b);
        return
    }
    var a = -1;
    if (status <= a++) {
        cm.dispose()
    } else {
        if (status === a++) {
            cm.curNodeEventEnd(true);
            cm.setInGameDirectionMode(true, false);
            cm.setStandAloneMode(true);
            cm.spawnNpcForPlayer(2540001, -850, 2300);
            cm.inGameDirectionEvent_AskAnswerTime(30)
        } else {
            if (status === a++) {
                cm.fieldEffect_InsertCanvas(1, 128, 0, 0, 0, 1000, 0);
                cm.inGameDirectionEvent_AskAnswerTime(1000)
            } else {
                if (status === a++) {
                    cm.inGameDirectionEvent_Monologue(header + "#fs22#在黑魔法师的影响下，变得狂暴的猴子们正在攻击人类。\r\n\r\n啊，那边有人受到了猴子的攻击，看那边！", 30000)
                } else {
                    if (status === a++) {
                        cm.fieldEffect_InsertCanvas(0, 0, 0, 0, 1000, 0, 0);
                        cm.inGameDirectionEvent_PushMoveInfo(0, 1000, 0, 2500)
                    } else {
                        if (status === a++) {
                            cm.inGameDirectionEvent_AskAnswerTime(4000)
                        } else {
                            if (status === a++) {
                                cm.inGameDirectionEvent_PushMoveInfo(1, 0, 0, 0)
                            } else {
                                if (status === a++) {
                                    cm.inGameDirectionEvent_AskAnswerTime(1000)
                                } else {
                                    if (status === a++) {
                                        cm.fieldEffect_InsertCanvas(1, 128, 0, 0, 0, 1000, 0);
                                        cm.inGameDirectionEvent_AskAnswerTime(1000)
                                    } else {
                                        if (status === a++) {
                                            cm.inGameDirectionEvent_Monologue("#fn黑体##fs22#你去将所有的猴子驱逐出去，然后救助那里的人们。我随后会为你打开通往下一层的门。\r\n\r\n如果受伤的探险家死去的话，你将无法进入下一层，所以要注意。", 30000)
                                        } else {
                                            if (status === a++) {
                                                cm.sendNextSNoESC("#b（要不要问问需要捕捉多少个呢？）")
                                            } else {
                                                if (status === a++) {
                                                    cm.sendNextNoESC("左，右，左，右……我数数……", 2540000)
                                                } else {
                                                    if (status === a++) {
                                                        cm.sendNextSNoESC("#b（不管了，我先上了！）")
                                                    } else {
                                                        if (status === a++) {
                                                            cm.fieldEffect_InsertCanvas(0, 0, 0, 0, 1000, 0, 0);
                                                            cm.curNodeEventEnd(true);
                                                            cm.setInGameDirectionMode(false, true);
                                                            cm.setStandAloneMode(false);
                                                            startMap(b)
                                                        } else {
                                                            cm.dispose()
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

function startMap(a) {
    cm.dispose();
    var b = cm.getMap().getPortal(1).getPosition();
    cm.onTeleport(1, cm.getPlayer().getId(), b.getX(), b.getY());
    a.setProperty("stage" + parseInt(level), "start");
    cm.getMap().getWeatherEffectNotice("请你守护好那名被狂暴的猴子伤害的探险家。", 147, 60000, 1);
    cm.fieldEffect_ScreenMsg("UI/UIWindowPL.img/HiddenCatch/StageImg/start")
}

function start() {
    status = -1;
    action(1, 0, 0)
};